home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / Connections.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  11.5 KB  |  353 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Connections.p
  3.  
  4.      Contains:    Communications Toolbox Connection Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT Connections;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __CONNECTIONS__}
  30. {$SETC __CONNECTIONS__ := 1}
  31.  
  32. {$I+}
  33. {$SETC ConnectionsIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __WINDOWS__}
  38. {$I Windows.p}
  39. {$ENDC}
  40. {    Types.p                                                        }
  41. {        ConditionalMacros.p                                        }
  42. {    Memory.p                                                    }
  43. {        MixedMode.p                                                }
  44. {    Quickdraw.p                                                    }
  45. {        QuickdrawText.p                                            }
  46. {    Events.p                                                    }
  47. {        OSUtils.p                                                }
  48. {    Controls.p                                                    }
  49. {        Menus.p                                                    }
  50.  
  51. {$IFC UNDEFINED __DIALOGS__}
  52. {$I Dialogs.p}
  53. {$ENDC}
  54. {    Errors.p                                                    }
  55. {    TextEdit.p                                                    }
  56.  
  57. {$IFC UNDEFINED __CTBUTILITIES__}
  58. {$I CTBUtilities.p}
  59. {$ENDC}
  60. {    StandardFile.p                                                }
  61. {        Files.p                                                    }
  62. {    AppleTalk.p                                                    }
  63.  
  64. {$PUSH}
  65. {$ALIGN MAC68K}
  66. {$LibExport+}
  67.  
  68. CONST
  69. {    current Connection Manager version    }
  70.     curCMVersion                = 2;
  71. {    current Connection Manager Environment Record version     }
  72.     curConnEnvRecVers            = 0;
  73. { CMErr }
  74.     cmGenericError                = -1;
  75.     cmNoErr                        = 0;
  76.     cmRejected                    = 1;
  77.     cmFailed                    = 2;
  78.     cmTimeOut                    = 3;
  79.     cmNotOpen                    = 4;
  80.     cmNotClosed                    = 5;
  81.     cmNoRequestPending            = 6;
  82.     cmNotSupported                = 7;
  83.     cmNoTools                    = 8;
  84.     cmUserCancel                = 9;
  85.     cmUnknownError                = 11;
  86.  
  87.     
  88. TYPE
  89.     CMErr = OSErr;
  90.  
  91.  
  92. CONST
  93.     cmData                        = 1 * (2**(0));
  94.     cmCntl                        = 1 * (2**(1));
  95.     cmAttn                        = 1 * (2**(2));
  96.     cmDataNoTimeout                = 1 * (2**(4));
  97.     cmCntlNoTimeout                = 1 * (2**(5));
  98.     cmAttnNoTimeout                = 1 * (2**(6));
  99.     cmDataClean                    = 1 * (2**(8));
  100.     cmCntlClean                    = 1 * (2**(9));
  101.     cmAttnClean                    = 1 * (2**(10));
  102. {        Only for CMRecFlags (not CMChannel) in the rest of this enum    }
  103.     cmNoMenus                    = 1 * (2**(16));
  104.     cmQuiet                        = 1 * (2**(17));
  105.     cmConfigChanged                = 1 * (2**(18));
  106.  
  107. { CMRecFlags and CMChannel        }
  108. {        Low word of CMRecFlags is same as CMChannel    }
  109.     
  110. TYPE
  111.     CMRecFlags = LONGINT;
  112.  
  113.     CMChannel = INTEGER;
  114.  
  115.  
  116. CONST
  117.     cmStatusOpening                = 1 * (2**(0));
  118.     cmStatusOpen                = 1 * (2**(1));
  119.     cmStatusClosing                = 1 * (2**(2));
  120.     cmStatusDataAvail            = 1 * (2**(3));
  121.     cmStatusCntlAvail            = 1 * (2**(4));
  122.     cmStatusAttnAvail            = 1 * (2**(5));
  123.     cmStatusDRPend                = 1 * (2**(6));                    { data read pending    }
  124.     cmStatusDWPend                = 1 * (2**(7));                    { data write pending    }
  125.     cmStatusCRPend                = 1 * (2**(8));                    { cntl read pending    }
  126.     cmStatusCWPend                = 1 * (2**(9));                    { cntl write pending    }
  127.     cmStatusARPend                = 1 * (2**(10));                { attn read pending    }
  128.     cmStatusAWPend                = 1 * (2**(11));                { attn write pending    }
  129.     cmStatusBreakPend            = 1 * (2**(12));
  130.     cmStatusListenPend            = 1 * (2**(13));
  131.     cmStatusIncomingCallPresent    = 1 * (2**(14));
  132.     cmStatusReserved0            = 1 * (2**(15));
  133.  
  134.     
  135. TYPE
  136.     CMStatFlags = LONGINT;
  137.  
  138.  
  139. CONST
  140.     cmDataIn                    = 0;
  141.     cmDataOut                    = 1;
  142.     cmCntlIn                    = 2;
  143.     cmCntlOut                    = 3;
  144.     cmAttnIn                    = 4;
  145.     cmAttnOut                    = 5;
  146.     cmRsrvIn                    = 6;
  147.     cmRsrvOut                    = 7;
  148.  
  149.     
  150. TYPE
  151.     CMBufFields = INTEGER;
  152.  
  153.     CMBuffers = ARRAY [0..7] OF Ptr;
  154.  
  155.     CMBufferSizes = ARRAY [0..7] OF LONGINT;
  156.  
  157.  
  158. CONST
  159.     cmSearchSevenBit            = 1 * (2**(0));
  160.  
  161.     
  162. TYPE
  163.     CMSearchFlags = INTEGER;
  164.  
  165.  
  166. CONST
  167.     cmFlagsEOM                    = 1 * (2**(0));
  168.  
  169.     
  170. TYPE
  171.     CMFlags = INTEGER;
  172.  
  173.     ConnEnvironRec = RECORD
  174.         version:                INTEGER;
  175.         baudRate:                LONGINT;
  176.         dataBits:                INTEGER;
  177.         channels:                CMChannel;
  178.         swFlowControl:            BOOLEAN;
  179.         hwFlowControl:            BOOLEAN;
  180.         flags:                    CMFlags;
  181.     END;
  182.  
  183.     ConnEnvironRecPtr = ^ConnEnvironRec;
  184.  
  185.     ConnPtr = ^ConnRecord;
  186.     ConnHandle = ^ConnPtr;
  187.  
  188.     ConnectionToolDefProcPtr = ProcPtr;  { FUNCTION ConnectionToolDef(hConn: ConnHandle; msg: INTEGER; p1: LONGINT; p2: LONGINT; p3: LONGINT): LONGINT; }
  189.     ConnectionSearchCallBackProcPtr = ProcPtr;  { PROCEDURE ConnectionSearchCallBack(hConn: ConnHandle; matchPtr: Ptr; refNum: LONGINT); }
  190.     ConnectionCompletionProcPtr = ProcPtr;  { PROCEDURE ConnectionCompletion(hConn: ConnHandle); }
  191.     ConnectionChooseIdleProcPtr = ProcPtr;  { PROCEDURE ConnectionChooseIdle; }
  192.     ConnectionToolDefUPP = UniversalProcPtr;
  193.     ConnectionSearchCallBackUPP = UniversalProcPtr;
  194.     ConnectionCompletionUPP = UniversalProcPtr;
  195.     ConnectionChooseIdleUPP = UniversalProcPtr;
  196.  
  197.     ConnRecord = RECORD
  198.         procID:                    INTEGER;
  199.         flags:                    CMRecFlags;
  200.         errCode:                CMErr;
  201.         refCon:                    LONGINT;
  202.         userData:                LONGINT;
  203.         defProc:                ConnectionToolDefUPP;
  204.         config:                    Ptr;
  205.         oldConfig:                Ptr;
  206.         asyncEOM:                LONGINT;
  207.         reserved1:                LONGINT;
  208.         reserved2:                LONGINT;
  209.         cmPrivate:                Ptr;
  210.         bufferArray:            CMBuffers;
  211.         bufSizes:                CMBufferSizes;
  212.         mluField:                LONGINT;
  213.         asyncCount:                CMBufferSizes;
  214.     END;
  215.  
  216.  
  217. CONST
  218. { CMIOPB constants and structure }
  219.     cmIOPBQType                    = 10;
  220.     cmIOPBversion                = 0;
  221.  
  222.  
  223. TYPE
  224.     CMIOPB = RECORD
  225.         qLink:                    QElemPtr;
  226.         qType:                    INTEGER;                                { cmIOPBQType }
  227.         hConn:                    ConnHandle;
  228.         theBuffer:                Ptr;
  229.         count:                    LONGINT;
  230.         flags:                    CMFlags;
  231.         userCompletion:            ConnectionCompletionUPP;
  232.         timeout:                LONGINT;
  233.         errCode:                CMErr;
  234.         channel:                CMChannel;
  235.         asyncEOM:                LONGINT;
  236.         reserved1:                LONGINT;
  237.         reserved2:                INTEGER;
  238.         version:                INTEGER;                                { cmIOPBversion }
  239.         refCon:                    LONGINT;                                { for application }
  240.         toolData1:                LONGINT;                                { for tool }
  241.         toolData2:                LONGINT;                                { for tool }
  242.     END;
  243.  
  244.     CMIOPBPtr = ^CMIOPB;
  245.  
  246. CONST
  247.     uppConnectionToolDefProcInfo = $0000FEF0; { FUNCTION (4 byte param, 2 byte param, 4 byte param, 4 byte param, 4 byte param): 4 byte result; }
  248.     uppConnectionSearchCallBackProcInfo = $00000FC0; { PROCEDURE (4 byte param, 4 byte param, 4 byte param); }
  249.     uppConnectionCompletionProcInfo = $000000C0; { PROCEDURE (4 byte param); }
  250.     uppConnectionChooseIdleProcInfo = $00000000; { PROCEDURE ; }
  251.  
  252. FUNCTION CallConnectionToolDefProc(hConn: ConnHandle; msg: INTEGER; p1: LONGINT; p2: LONGINT; p3: LONGINT; userRoutine: ConnectionToolDefUPP): LONGINT;
  253.     {$IFC NOT GENERATINGCFM}
  254.     INLINE $205F, $4E90;
  255.     {$ENDC}
  256.  
  257. PROCEDURE CallConnectionSearchCallBackProc(hConn: ConnHandle; matchPtr: Ptr; refNum: LONGINT; userRoutine: ConnectionSearchCallBackUPP);
  258.     {$IFC NOT GENERATINGCFM}
  259.     INLINE $205F, $4E90;
  260.     {$ENDC}
  261.  
  262. PROCEDURE CallConnectionCompletionProc(hConn: ConnHandle; userRoutine: ConnectionCompletionUPP);
  263.     {$IFC NOT GENERATINGCFM}
  264.     INLINE $205F, $4E90;
  265.     {$ENDC}
  266.  
  267. PROCEDURE CallConnectionChooseIdleProc(userRoutine: ConnectionChooseIdleUPP);
  268.     {$IFC NOT GENERATINGCFM}
  269.     INLINE $205F, $4E90;
  270.     {$ENDC}
  271.  
  272. FUNCTION NewConnectionToolDefProc(userRoutine: ConnectionToolDefProcPtr): ConnectionToolDefUPP;
  273.     {$IFC NOT GENERATINGCFM }
  274.     INLINE $2E9F;
  275.     {$ENDC}
  276.  
  277. FUNCTION NewConnectionSearchCallBackProc(userRoutine: ConnectionSearchCallBackProcPtr): ConnectionSearchCallBackUPP;
  278.     {$IFC NOT GENERATINGCFM }
  279.     INLINE $2E9F;
  280.     {$ENDC}
  281.  
  282. FUNCTION NewConnectionCompletionProc(userRoutine: ConnectionCompletionProcPtr): ConnectionCompletionUPP;
  283.     {$IFC NOT GENERATINGCFM }
  284.     INLINE $2E9F;
  285.     {$ENDC}
  286.  
  287. FUNCTION NewConnectionChooseIdleProc(userRoutine: ConnectionChooseIdleProcPtr): ConnectionChooseIdleUPP;
  288.     {$IFC NOT GENERATINGCFM }
  289.     INLINE $2E9F;
  290.     {$ENDC}
  291.  
  292. FUNCTION InitCM: CMErr;
  293. FUNCTION CMGetVersion(hConn: ConnHandle): Handle;
  294. FUNCTION CMGetCMVersion: INTEGER;
  295. FUNCTION CMNew(procID: INTEGER; flags: CMRecFlags; VAR desiredSizes: CMBufferSizes; refCon: LONGINT; userData: LONGINT): ConnHandle;
  296. PROCEDURE CMDispose(hConn: ConnHandle);
  297. FUNCTION CMListen(hConn: ConnHandle; async: BOOLEAN; completor: ConnectionCompletionUPP; timeout: LONGINT): CMErr;
  298. FUNCTION CMAccept(hConn: ConnHandle; accept: BOOLEAN): CMErr;
  299. FUNCTION CMOpen(hConn: ConnHandle; async: BOOLEAN; completor: ConnectionCompletionUPP; timeout: LONGINT): CMErr;
  300. FUNCTION CMClose(hConn: ConnHandle; async: BOOLEAN; completor: ConnectionCompletionUPP; timeout: LONGINT; now: BOOLEAN): CMErr;
  301. FUNCTION CMAbort(hConn: ConnHandle): CMErr;
  302. FUNCTION CMStatus(hConn: ConnHandle; VAR sizes: CMBufferSizes; VAR flags: CMStatFlags): CMErr;
  303. PROCEDURE CMIdle(hConn: ConnHandle);
  304. PROCEDURE CMReset(hConn: ConnHandle);
  305. PROCEDURE CMBreak(hConn: ConnHandle; duration: LONGINT; async: BOOLEAN; completor: ConnectionCompletionUPP);
  306. FUNCTION CMRead(hConn: ConnHandle; theBuffer: UNIV Ptr; VAR toRead: LONGINT; theChannel: CMChannel; async: BOOLEAN; completor: ConnectionCompletionUPP; timeout: LONGINT; VAR flags: CMFlags): CMErr;
  307. FUNCTION CMWrite(hConn: ConnHandle; theBuffer: UNIV Ptr; VAR toWrite: LONGINT; theChannel: CMChannel; async: BOOLEAN; completor: ConnectionCompletionUPP; timeout: LONGINT; flags: CMFlags): CMErr;
  308. FUNCTION CMIOKill(hConn: ConnHandle; which: INTEGER): CMErr;
  309. PROCEDURE CMActivate(hConn: ConnHandle; activate: BOOLEAN);
  310. PROCEDURE CMResume(hConn: ConnHandle; resume: BOOLEAN);
  311. FUNCTION CMMenu(hConn: ConnHandle; menuID: INTEGER; item: INTEGER): BOOLEAN;
  312. FUNCTION CMValidate(hConn: ConnHandle): BOOLEAN;
  313. PROCEDURE CMDefault(VAR theConfig: Ptr; procID: INTEGER; allocate: BOOLEAN);
  314. FUNCTION CMSetupPreflight(procID: INTEGER; VAR magicCookie: LONGINT): Handle;
  315. FUNCTION CMSetupFilter(procID: INTEGER; theConfig: UNIV Ptr; count: INTEGER; theDialog: DialogPtr; VAR theEvent: EventRecord; VAR theItem: INTEGER; VAR magicCookie: LONGINT): BOOLEAN;
  316. PROCEDURE CMSetupSetup(procID: INTEGER; theConfig: UNIV Ptr; count: INTEGER; theDialog: DialogPtr; VAR magicCookie: LONGINT);
  317. PROCEDURE CMSetupItem(procID: INTEGER; theConfig: UNIV Ptr; count: INTEGER; theDialog: DialogPtr; VAR theItem: INTEGER; VAR magicCookie: LONGINT);
  318. PROCEDURE CMSetupXCleanup(procID: INTEGER; theConfig: UNIV Ptr; count: INTEGER; theDialog: DialogPtr; OKed: BOOLEAN; VAR magicCookie: LONGINT);
  319. PROCEDURE CMSetupPostflight(procID: INTEGER);
  320. FUNCTION CMGetConfig(hConn: ConnHandle): Ptr;
  321. FUNCTION CMSetConfig(hConn: ConnHandle; thePtr: UNIV Ptr): INTEGER;
  322. FUNCTION CMIntlToEnglish(hConn: ConnHandle; inputPtr: UNIV Ptr; VAR outputPtr: Ptr; language: INTEGER): OSErr;
  323. FUNCTION CMEnglishToIntl(hConn: ConnHandle; inputPtr: UNIV Ptr; VAR outputPtr: Ptr; language: INTEGER): OSErr;
  324. FUNCTION CMAddSearch(hConn: ConnHandle; theString: ConstStr255Param; flags: CMSearchFlags; callBack: ConnectionSearchCallBackUPP): LONGINT;
  325. PROCEDURE CMRemoveSearch(hConn: ConnHandle; refnum: LONGINT);
  326. PROCEDURE CMClearSearch(hConn: ConnHandle);
  327. FUNCTION CMGetConnEnvirons(hConn: ConnHandle; VAR theEnvirons: ConnEnvironRec): CMErr;
  328. FUNCTION CMChoose(VAR hConn: ConnHandle; where: Point; idle: ConnectionChooseIdleUPP): INTEGER;
  329. PROCEDURE CMEvent(hConn: ConnHandle; {CONST}VAR theEvent: EventRecord);
  330. PROCEDURE CMGetToolName(procID: INTEGER; VAR name: Str255);
  331. FUNCTION CMGetProcID(name: ConstStr255Param): INTEGER;
  332. PROCEDURE CMSetRefCon(hConn: ConnHandle; refCon: LONGINT);
  333. FUNCTION CMGetRefCon(hConn: ConnHandle): LONGINT;
  334. FUNCTION CMGetUserData(hConn: ConnHandle): LONGINT;
  335. PROCEDURE CMSetUserData(hConn: ConnHandle; userData: LONGINT);
  336. PROCEDURE CMGetErrorString(hConn: ConnHandle; id: INTEGER; VAR errMsg: Str255);
  337. FUNCTION CMNewIOPB(hConn: ConnHandle; VAR theIOPB: CMIOPBPtr): CMErr;
  338. FUNCTION CMDisposeIOPB(hConn: ConnHandle; theIOPB: CMIOPBPtr): CMErr;
  339. FUNCTION CMPBRead(hConn: ConnHandle; theIOPB: CMIOPBPtr; async: BOOLEAN): CMErr;
  340. FUNCTION CMPBWrite(hConn: ConnHandle; theIOPB: CMIOPBPtr; async: BOOLEAN): CMErr;
  341. FUNCTION CMPBIOKill(hConn: ConnHandle; theIOPB: CMIOPBPtr): CMErr;
  342.  
  343. {$ALIGN RESET}
  344. {$POP}
  345.  
  346. {$SETC UsingIncludes := ConnectionsIncludes}
  347.  
  348. {$ENDC} {__CONNECTIONS__}
  349.  
  350. {$IFC NOT UsingIncludes}
  351.  END.
  352. {$ENDC}
  353.